import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

void main() => runApp(const PageViewCustomWidget());

class PageViewCustomWidget extends StatelessWidget {
  const PageViewCustomWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Test',
      home: Scaffold(
          appBar: AppBar(title: const Text('Flutter 可滚动Widget -- PageView')),
          body: PageView.custom(
            onPageChanged: (index) {
              if (kDebugMode) {
                print('current page $index ');
              }
            },
            childrenDelegate: SliverChildListDelegate(<Widget>[
              const ListTile(title: Text('Title0')),
              const ListTile(title: Text('Title1')),
              const ListTile(title: Text('Title2')),
              const ListTile(title: Text('Title3')),
              const ListTile(title: Text('Title4')),
            ]),
          )),
    );
  }
}
